package com.power.sifa.approve.model;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
*  申请材料附件实体类
*/

@Entity
@ApiModel(value="申请材料附件")
@Data
@Table(name="Apl_attachment",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Apl_attachment.Apl_attachmentPK.class) 用于复合组件
public class Apl_attachment extends BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "applyid+attachmentid")
    private String id;

    @ApiModelProperty(value = "附件id")
    private String attachmentid;

    @ApiModelProperty(value = "上传时间", example="2020-10-22 10:03:22")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createtime;

    @ApiModelProperty(value = "引用主表id")
    private String applyid;

    @ApiModelProperty(value = "引用申请材料id")
    private String matter_attachid;

    @ApiModelProperty(value = "是否已读")
    private Integer isread;

    /**
     *  是否已读文本
     */
    @Transient
    @FieldEnumText(eum="yesNo", valuefield="isread")
    private String isread_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("attachmentid", this.getAttachmentid());
        map.put("createtime", this.getCreatetime());
        map.put("applyid", this.getApplyid());
        map.put("matter_attachid", this.getMatter_attachid());
        map.put("isread_text", this.isread_text);
        map.put("isread", this.getIsread());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_attachmentPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Apl_attachmentPK pk = (Apl_attachmentPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
